<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>AdminLTE 2 | Data Tables</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <!--<link rel="stylesheet" href="/adminlte/bower_components/bootstrap/dist/css/bootstrap.min.css">-->
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">

    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/ionicons/2.0.0/css/ionicons.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="/adminlte/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="/adminlte/dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="/adminlte/dist/css/skins/_all-skins.min.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- Google Font -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
  </head>
  <body >


    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        菜单管理
        <!--<small></small>-->
      </h1>
      <ol class="breadcrumb">
        <li>
          <a href="/menu/listPage"><button class="btn btn-xs jfedit btn-default">刷新</button></a>&nbsp;
          <a href="/menu/addPage"><button class="btn btn-xs jfedit btn-primary">新增</button></a>
        </li>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <!--<div class="box-header">-->
            <!--<h3 class="box-title">Hover Data Table</h3>-->
            <!--</div>-->
            <!-- /.box-header -->
            <div class="box-body">
              <table id="example" class="table table-bordered table-hover">

                <thead>
                  <tr>
                    <th>序号</th>
                    <th>菜单名称</th>
                    <th>菜单树</th>
                    <th>排序号</th>
                    <th>url</th>
                    <th>type</th>
                    <th>操作</th>


                  </tr>
                </thead>
                <tbody>


                </tbody>
                <tfoot>
                  <tr>
                    <th>序号</th>
                    <th>菜单名称</th>
                    <th>菜单树</th>
                    <th>排序号</th>
                    <th>url</th>
                    <th>type</th>
                    <th>操作</th>

                  </tr>
                </tfoot>
              </table>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->


        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->


    <!-- jQuery 3 -->
    <script src="/adminlte/bower_components/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap 3.3.7 -->
    <script src="/adminlte/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- DataTables -->
    <script src="/adminlte/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="/adminlte/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <!-- SlimScroll -->
    <script src="/adminlte/bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
    <!-- FastClick -->
    <script src="/adminlte/bower_components/fastclick/lib/fastclick.js"></script>
    <!-- AdminLTE App -->
    <script src="/adminlte/dist/js/adminlte.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="/adminlte/dist/js/demo.js"></script>
    <!-- page script -->
    <script>
<!--$(function () {-->
  <!--$('#example').DataTable({-->
    <!--"ajax":-->
    <!--{-->
      <!--"url": "/menu/list",-->
      <!--"dataType": "JSON",-->
      <!--"dataSrc": "",-->
      <!--"columns": [-->
        <!--{ "data": "id" },-->
        <!--{ "data": "name"},-->
        <!--{ "data": "url" },-->
        <!--{ "data": "type" }-->
      <!--]-->
     <!--}-->
   <!--})-->
<!--})-->


$(document).ready(function() {
    $('#example').DataTable( {
        "order": [[ 2, "asc" ]],
        "ajax": "/menu/list",
        "columns": [
            { "data": "id" },
            { "data": "name" },
            { "data": "treeName" },
            { "data": "orderNo" },
            { "data": "url" },
            { "data": "type" },
            { "data": "type" }
        ],
        "aoColumnDefs":[
                    {//倒数第一列
                        "targets":-1,
                        "bSortable": false,
                        render: function(data, type, row) {
                            var html ='<a href="/menu/editPage?id='+row.id+'"><button class="btn btn-xs jfedit btn-info" value="'+row.id+'">编辑</button></a>&nbsp;&nbsp;&nbsp;&nbsp;'
                            +'<button onclick="delFun('+row.id+')" id="delButton" class="btn btn-xs btn-danger jfdelete" value="'+row.id+'">删除</button>';
                            return html;
                        }
                    },
                   ]
    } );
} );

  function delFun(id){
    if(confirm("确定删除嘛？")){
      $.ajax({
        url:"/menu/delete?id=" + id,
        success:function(data){
          window.location.href="/menu/listPage";
        }
      });
    };
  }
</script>
  </body>
</html>
